/*
 * @Description:
 * @Author: xuqi
 * @Github: https://github.com/knight-peter
 * @LastEditors: xuqi
 */
import * as types from "@/store/mutation_types";

const mutations = {
  changeNavActiveIndex(state, index) {
    state.navActive = index;
    // console.log(state.navActive);
  },
  /* 登陆 */
  [types.LOGIN]: (state, value) => {
    console.log({
      LOGIN_value: value,
      state
    });
    state.token = value;
  },
  /* 用户信息 */
  [types.USERINFO]: (state, info) => {
    state.userInfo = info;
  },
  /* 登陆状态 */
  [types.LOGINSTATUS]: (state, bool) => {
    state.loginStatus = bool;
  },
  /* 保存账号密码 */
  updateLoginInfo: (state, data) => {
    if (data.mobile) {
      state.loginInfo.mobile = data.mobile;
    }
    if (data.password) {
      state.loginInfo.password = data.password;
    }
  },
  /* 更新个人资料 */
  updateUserInfo: (state, data) => {
    if (data.parent_number) {
      state.userInfo.parent_number = data.parent_number;
    }
    if (data.bank) {
      state.userInfo.bank = data.bank;
    }
    if (data.bankcard) {
      state.userInfo.bankcard = data.bankcard;
    }
    if (data.id_card) {
      state.userInfo.id_card = data.id_card;
    }
    if (data.mobile) {
      state.userInfo.mobile = data.mobile;
    }
    if (data.realname) {
      state.userInfo.realname = data.realname;
    }
    if (data.receiver_address) {
      state.userInfo.receiver_address = data.receiver_address;
    }
    if (data.receiver_area_name) {
      state.userInfo.receiver_area_name = data.receiver_area_name;
    }
    if (data.receiver_area_code) {
      state.userInfo.receiver_area_code = data.receiver_area_code;
    }
  }
};
export default mutations;
